<?php

namespace App\Models\Article;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

use App\Models\Article\Article;

class Type extends Model
{
    use HasFactory;

    //约定表名
    protected $table = "article_type";

    //取消自动插入时间戳
    public $timestamps = false;

    //分类下面的文章总数
    public function getCountAttribute()
    {
        //获取主键ID
        $typeid = $this->id;

        return Article::where(['typeid' => $typeid])->count();
    }
}
